require "rubygems"
require "activerecord"

class TestMigrated
  @@_ar_test_migrated = false
  def self._ar_test_migrated
    @@_ar_test_migrated
  end
  
  def self._ar_test_migrated=(val)
    @@_ar_test_migrated = val
  end
end

module ActiveRecordTestCase
  def setup
    begin
      ActiveRecord::Base.connection
    rescue
      logger = Logger.new(STDOUT)
      logger.level = Logger::ERROR
      ActiveRecord::Base.logger = logger
      ActiveRecord::Base.establish_connection(
        :adapter => "sqlite3",
        :database => ":memory:"
      )    
      ActiveRecord::Migrator.migrate(File.join(File.dirname(__FILE__), "..", "..", "lib", "wondercap", "lib", "deployment", "model", "migrations"))
    end
  end
end